import {rpxToPx} from "../utils/util"
import {imageUrl} from "../utils/imageutil"
Page({

  data: {
    imageUrl,
    car_id:'',
    scrollH:100,
    l_list:[],
    l_index:0,
    r_list:[],
    r_index:0
  },

 
  onLoad(options) {
    if(options.id){
      this.setData({
        car_id:options.id
      })
    }
    this.setData({
      scrollH: getApp().globalData.windowHeight - rpxToPx(132 + 220) - getApp().globalData.barUsableBottom
    })
    this.vehicle_good()
  },

  vehicle_good(){
    getApp().globalData.posts('/index.php/api/app/user/sorting/ouyoung_api/vehicle_good').then(res => {
      this.setData({
        l_list:res.data.data,
      })
      this.vehicle_goodgg()
    })
  },

  vehicle_goodgg(){
    getApp().globalData.posts('/index.php/api/app/user/sorting/ouyoung_api/vehicle_goodgg?id='+this.data.l_list[this.data.l_index].id).then(res => {
      this.setData({
        r_list:res.data.data
      })
    })
  },


  change_l_index(e){
    let l_index = e.currentTarget.dataset.index
    if(this.data.l_index==l_index){
      return
    }
    this.setData({
      l_index,
      r_index:0
    })
    this.vehicle_goodgg()
  },
  change_r_index(e){
    let r_index = e.currentTarget.dataset.index
    this.setData({
      r_index
    })
  },
  bottomTap(){
    let info = JSON.stringify(this.data.r_list[this.data.r_index])
    wx.navigateTo({
      url: './order?info='+info+'&car_id='+this.data.car_id,
    })
  },

  to_webview(){
    wx.setStorageSync('xieyiImageArr', [imageUrl+'/xiche/banner_details.png'])
    wx.navigateTo({
      url: '/pages/webview/index',
    })
  },

})